package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class P1015 {

	public static void main(String[] args)
	throws Exception {

		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        String line;
        int c = 0;
        String[] ps;
        String s = "";

        line = stdin.readLine().trim();
        while (!"0 0".equals(line)) {
        	c ++;
        	ps = line.split("\\s+");
        	int n = Integer.valueOf(ps[0]);
        	int m = Integer.valueOf(ps[1]);
        	
        	int[][] dp = new int[n][];
        	for (int i = 0; i < n; i ++) {
                line = stdin.readLine().trim();
                ps = line.split("\\s+");
                int d = Integer.valueOf(ps[0]);
                int p = Integer.valueOf(ps[1]);
        		dp[i] = new int[] {d, p};
        	}
            s += "Jury #" + c + "\n" + resultToString(jury(m, dp)) + "\n";
            while ((line = stdin.readLine().trim()) != null) {
            	if (line.length() > 0) {
            		break;
            	}
            }
        }
		
		System.out.println(s);
	}
	
	@SuppressWarnings("unchecked")
	private static String resultToString(Map map) {
		String str = "Best jury has value " + map.get("p") + " for prosecution and value " + map.get("d") + " for defence:\n";
		List<Integer> t = (List<Integer>)map.get("v");
		Integer[] v = t.toArray(new Integer[t.size()]);
		Arrays.sort(v);
		for (int i : v) {
			str += " " + (i+1);
		}
		return str;
	}

	@SuppressWarnings("unchecked")
	private static Map jury(int m, int[][] dp) {
	
		List<Map<Integer, Map>> tmp = new ArrayList<Map<Integer, Map>>();
		Map tr = new HashMap();
		tr.put("d", 0);
		tr.put("p", 0);
		tr.put("v", new ArrayList());
		Map<Integer, Map> t0 = new HashMap<Integer, Map>();
		t0.put(0, tr);
		tmp.add(t0);
		
		for (int i = 1; i <= m; i ++) {
			Map<Integer, Map> t = tmp.get(i-1);
			Map<Integer, Map> ti = new HashMap<Integer, Map>();
			for (int k = -20*i; k <= 20*i; k ++) {
				for (int j = 0; j < dp.length; j ++) {
					int a = dp[j][0]-dp[j][1];
					int b = dp[j][0]+dp[j][1];
					Map r = t.get(k-a);
					if (r == null) {
						continue;
					} else {
						if (((List<Integer>)r.get("v")).contains(j)) {
							continue;
						} else {
							if (b <= 0) {
								continue;
							} else {
								Map nr = new HashMap();
								nr.put("d", ((Integer)r.get("d"))+dp[j][1]);
								nr.put("p", ((Integer)r.get("p"))+dp[j][0]);
								List<Integer> nv = new ArrayList<Integer>((List<Integer>)r.get("v"));
								nv.add(j);
								nr.put("v", nv);
								ti.put(k, nr);
							}
						}
					}
				}
			}
			tmp.add(ti);
		}
		//return
		Map<Integer, Map> map = tmp.get(m);
		int i = Integer.MAX_VALUE;
		for (int k: map.keySet()) {
			if (Math.abs(k) < Math.abs(i)) {
				i = k;
			}
		}
		return map.get(i);
	}
}
